package com.shu.project.service.impl;

import com.shu.project.dao.GoodsDao;
import com.shu.project.dao.SeckillGoodsDao;
import com.shu.project.model.Goods;
import com.shu.project.service.IGoodsService;
import com.shu.project.vo.GoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("goodsService")
public class GoodsServiceImpl implements IGoodsService {
    @Autowired
    GoodsDao goodsDao;
    @Autowired
    SeckillGoodsDao seckillGoodsDao;
    @Override
    public List<GoodsVo> queryGoodsAll() {

        return goodsDao.queryGoodsVoList();
    }
    @Override
    public GoodsVo queryGoodsVoById(Long id){
        GoodsVo goodsVo=goodsDao.queryGoodsVoById(id);
        return goodsVo;
    }

    @Override
    public boolean reduceStock(Long goodsId) {
        return seckillGoodsDao.reduceStock(goodsId)>0?true:false;
    }
}
